package com.cjy.hd13;

import java.sql.*;

public class JdbcCreate {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        // 导入驱动jar包
        // 注册驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //定义字符串内容是mysql地址
        String url = "jdbc:mysql://192.168.65.3:3306/hadoop?serverTimezone=UTC&characterEncoding=utf-8&useSSL=false";
        //获取数据库连接对象
        Connection conn = DriverManager.getConnection(url,"root","Aa123-456");
        //获取执行sql对象 Statement
        Statement statement = conn.createStatement();
        //定义sql语句
        String sql = "insert into `user` values('cjy',21,'男')";
        //执行sql
        statement.execute(sql);
        conn.close();
    }
}
